package problems;

import lib.MathLib;

public class Euler069Fast extends AbstractEuler {

	@Override
	public Number calculate() {
		long largestProductOfFirstPrimesBelowOneMillion = 1;
		for (long i = 1, prime = 2; ; i++, prime = MathLib.getPrime((int)i)) {
			if (largestProductOfFirstPrimesBelowOneMillion * prime > 1000000) {
				return largestProductOfFirstPrimesBelowOneMillion;
			} else {
				largestProductOfFirstPrimesBelowOneMillion *= prime;
				System.out.println(largestProductOfFirstPrimesBelowOneMillion);
			}
		}
		
	}

	@Override
	protected Number getCorrectAnswer() {
		return 510510L;
	}

}
